<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    autoCompleteExpPrice("expNameId");
    function autoCompleteExpPrice(inputId){
        var url="${ctx}/csm/expInfo/autoComplete?expDict.expCode=${expPrice.expInfo.expDict.expCode}";
        autoComplete(inputId,url,
            function(data){
                var rows = [];
                for(var i=0; i<data.length; i++){
                    rows[rows.length] = {
                        data:data[i],
                        value:data[i].id,
                        result:data[i].expDict.expName
                    };
                }
                return rows;
            },function(data, i, max){
                return data.expDict.expName+"|"+data.expDict.expCode+"|"+data.packageSpec;
            },function(event,data,formatted){
                $('#expInfoId').attr('value',data.id);
                $('#expDictId').attr('value',data.expDict.id);
                $('#packageSpec').attr('value',data.packageSpec);
                var select = document.getElementById("units");
                for(var i=0; i<select.options.length; i++){
                    if(select.options[i].value == data.packageUnit){
                        select.options[i].selected = true;
                        break;
                    }
                }
            })
    }

    $(function(){
        var startDate =$('#startDate').val();
        var date = currentTime();
        if(startDate<date){
            $('#date').val(date);
        }
    });
    function currentTime() {
        var now = new Date();
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var day = now.getDate();
        var hh = now.getHours();
        var mm = now.getMinutes();
        var ss = now.getSeconds();
        var clock = year + "-";
        if (month < 10)
            clock += "0";
        clock += month + "-";
        if (day < 10)
            clock += "0";
        clock += day + " ";
        if (hh < 10)
            clock += "0";
        clock += hh + ":";
        if (mm < 10)
            clock += '0';
        clock += mm + ":";
        if (ss < 10)
            clock += '0';
        clock += ss;
        return (clock);

    }

    function changePrice(inputId,inputId2){
        var inputValue = $.trim($("#"+inputId).val());
        if(inputValue!=null&&inputValue!=''){
            $("#"+inputId2).val(inputValue);
        }
    }
</script>
<div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"  onclick="loadDiv('priceRightDiv','${ctx}/csm/expPrice/indexModify?expInfo.expDict.expCode=${expPrice.expInfo.expDict.expCode}')">消耗品价格列表</a>
                </li>
                <li class="active">
                    <a href="#" >消耗品调价</a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-12">
                        <form:form id="inputForm" data-parsley-validate="" modelAttribute="expPrice" onsubmit="return formSaveLoad('priceRightDiv','inputForm','${ctx}/csm/expPrice/saveModify','${ctx}/csm/expPrice/indexModify?expInfo.expDict.expCode=${expPrice.expInfo.expDict.expCode}');" method="post" class="form-horizontal">
                            <form:hidden path="id"/>
                            <form:hidden path="orgId"/>
                            <form:hidden path="priceList.id"/>
                            <form:hidden path="expInfo.id" id="expInfoId"/>
                            <form:hidden path="expInfo.expDict.id" id="expDictId"/>
                            <div class="col-lg-6"><div class="form-group">
                                <label class="col-sm-2 control-label">消耗品信息：</label>
                                <div class="col-sm-4">
                                    <form:input path="expInfo.expDict.expName" id="expNameId" htmlEscape="false" class="form-control" />
                                </div>
                            </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">规格：</label>
                                    <div class="col-sm-4">
                                        <form:input path="packageSpec" id="packageSpec" htmlEscape="false" class="form-control"  maxlength="20" disabled="true"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">单位：</label>
                                    <div class="col-sm-4">
                                        <%--<form:input path="units" id="units" htmlEscape="false" class="form-control"  maxlength="2" readonly="true"/>--%>
                                        <form:select path="units" id="units" class="form-control"  disabled="true">
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('SPEC_UNIT')}" itemLabel="label" disabled="true" itemValue="value" htmlEscape="false"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">新批发价：</label>
                                    <div class="col-sm-4">
                                        <form:input path="tradePrice" id="tradePrice" htmlEscape="false" class="form-control" data-parsley-required="true" data-parsley-twonum="1" onblur="changePrice('tradePrice','retailPrice')"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">新零售价：</label>
                                    <div class="col-sm-4">
                                        <form:input path="retailPrice" id="retailPrice" htmlEscape="false" class="form-control" data-parsley-required="true" data-parsley-twonum="1" />
                                    </div>
                                </div>
                                    <%--update by CTQ at 2017-07-05 11:37:43 判断开始时间：如果开始时间小于当前时间，最小开始时间从当前时间开始，如果开始时间大于当前时间，最小开始时间从开始时间开始--%>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">启用时间：</label>
                                    <div class="col-sm-4">
                                        <input id="startDate" value="<fmt:formatDate value="${expPrice.startDate}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>" type="hidden"/>
                                        <input name="startDate" id="date" htmlEscape="false" class="form-control" data-parsley-required="true" readonly
                                               onfocus="var startDate =$('#startDate').val();if(startDate<currentTime()){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:currentTime()})}else{WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:startDate})}" value='<fmt:formatDate value="${expPrice.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>'/>

                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-6">

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">费用分类：</label>
                                    <div class="col-sm-4">
                                        <form:select path="classOnRcpt" class="form-control"   disabled="true">
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('OUTP_RCPT_FEE_DICT')}" itemLabel="label" disabled="true" itemValue="value" htmlEscape="false"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">核算项目：</label>
                                    <div class="col-sm-4">
                                        <form:select path="classOnReckoning" class="form-control"   disabled="true">
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('RECK_ITEM_CLASS_DICT')}" itemLabel="label" disabled="true" itemValue="value" htmlEscape="false"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">会计科目：</label>
                                    <div class="col-sm-4">
                                        <form:select path="subjCode" class="form-control"  disabled="true">
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('TALLY_SUBJECT_DICT')}" itemLabel="label" itemValue="value" htmlEscape="false" disabled="true"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">病案首页：</label>
                                    <div class="col-sm-4">
                                        <form:select path="classOnMr" class="form-control"  disabled="true" >
                                            <form:option value="" label=""/>
                                            <form:options items="${fns:getDictList('MR_FEE_CLASS_DICT')}" itemLabel="label" itemValue="value" htmlEscape="false" disabled="true"/>
                                        </form:select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">最高限价：</label>
                                    <div class="col-sm-4">
                                        <form:input path="priceMax" htmlEscape="false" class="form-control"  disabled="true" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">备注信息：</label>
                                    <div class="col-sm-4">
                                        <form:textarea path="remarks" htmlEscape="false" class="form-control" disabled="true"  maxlength="1000"/>
                                    </div>
                                </div>
                            </div>


                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('priceRightDiv','${ctx}/csm/expPrice/indexModify?expInfo.expDict.expCode=${expPrice.expInfo.expDict.expCode}')">
                                </div>
                            </div>
                        </form:form>
                    </div>

                </div>
            </section>
        </div>
    </div>